#Win32 console problems
$KCODE='u'

#RAILS

# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/rails/world'
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
Cucumber::Rails.use_transactional_fixtures
Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling 
# (e.g. rescue_action_in_public / rescue_responses / rescue_from)

require 'cucumber/rails/rspec'

# WATIR

require 'spec/expectations'
require 'firewatir'
BROWSER = FireWatir::Firefox
require 'watir/contrib/enabled_popup'
include Win32

#Including helpers

World do |world|
  world.extend Helpers
  world
end

#Cucumber hooks

# "before all"
browser = BROWSER.new

Before do
  @browser = browser
  #rolling back DB since each scenario should be run in 'clean' DB
  #raise "Couldn't run db:test:clone" unless system('rake.cmd db:test:clone')
  `rake.cmd db:test:clone`
end

# "after all"
at_exit do
  browser.close
end

